﻿@model IEnumerable<VietPremier.Areas.AdminCP.Models.AdminUserManager>
@{
    ViewBag.Title = "Quản lý thông tin tài khoản Admin";
    Layout = "~/Areas/AdminCP/Views/Shared/AdminLayout.cshtml";
}

<script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-1.7.min.js")" type="text/javascript"></script>
  <script src="@Url.Content("~/Content/cssAdmin/js/plugins/jquery-ui-1.8.16.custom.min.js")" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function () {

        $('#nofSuccess').hide();
        $('#nofError').hide();
    });
    function alertMsg(msg) {
        $('#nofSuccess').hide();
        $('#nofError').show();
        $('#msgNofError').text(msg);


    }
    function changeAccount() {
        var username = $('#username').val();
        var password = $('#password').val();
        var cpassword = $('#cpassword').val();

        var msg = "";

        if (username.length < 5 || password.length < 5) {
            msg = "! chiều dài username / password phải lớn hơn 6 ký tự";
            alertMsg(msg);
            return false;
        }
        if (username.length > 20 || password.length > 20) {
            msg = "! Độ dài username / password phải bé hơn 20 ký tự";
            alertMsg(msg);
            return false;
        }
        if (password != cpassword) {
            msg = "! password và confirm password: không khớp";
            alertMsg(msg);
            return false;
        }

        var postURL = '@Url.Action("changeAccount", "ProfileAdmin")';

        $.post(postURL, {"username": username, "password": password },
         function (data) {
             if (data.password == "!") //error
             {

                 alertMsg("! Lỗi SQL từ server / hosting");
             }
             else {
                 $('#nofError').hide();
                 $('#nofSuccess').show();
                 $('#msgNofSuccess').text("Thông tin của bạn đã cập nhật thành công !");
                            
             }
         });

    }
</script>

	<div class="maincontentinner">
            	
                <ul class="maintabmenu">
                	<li class="current"><a href="@Url.Content("~/Content/cssAdmin/dashboard.html")" >Thông tin cá nhân</a></li>
                </ul><!--maintabmenu-->
                
                    <div class="contenttitle">
                    	<h2 class="form"><span>Thay đổi password</span></h2>
                    </div><!--contenttitle-->
                    
                    <br />

                    <!-- phan nay la notification -->

                     <div class="notification msginfo" style="display:none" id="nofInfo">
                        <a class="close"></a>
                        <p id="msgNofInfo">This is an information message.</p>
                    </div><!-- notification msginfo -->
                    
                    <div class="notification msgsuccess" style="display:none" id="nofSuccess">
                        <a class="close"></a>
                        <p id="msgNofSuccess">This is a success message.</p>
                    </div><!-- notification msgsuccess -->
                    
                    <div class="notification msgalert" style="display:none" id="nofAlert">
                        <a class="close"></a>
                        <p id="msgNofAlert">This is an alert message.</p>
                    </div><!-- notification msgalert -->
                    
                    <div class="notification msgerror" style="display:none" id="nofError">
                        <a class="close"></a>
                        <p id="msgNofError">This is an error message.</p>
                    </div><!-- notification msgerror -->

                    <!-- -->

                    <form id="form2" class="stdform stdform2" method="post" action="#">
                    	<p>
                        	<label>Username</label>
                            @{
                                //Session["AdminId"] = "Admin";  // will delete
                                
                                var userId = " ";

                                if (Session["AdminId"] != null)
                                {
                                    userId = Session["AdminId"].ToString();
                                }
                             <span class="field"><input type="text" name="firstname" id="username" class="longinput" value="@userId" disabled="disabled" /></span>
                            }
                        </p>
                        
                        <p>
                        	<label>Password</label>
                            <span class="field"><input type="password" name="lastname" id="password" class="longinput" /></span>
                        </p>
                         
                         <p>
                        	<label>Nhập lại Password</label>
                            <span class="field"><input type="password" name="lastname" id="cpassword" class="longinput" /></span>
                        </p>

                        <p class="stdformbutton">
                        	<button class="submit radius2" onclick="changeAccount(); return false">Gửi</button>
                           
                        </p>
                    </form>
                    
                    <br clear="all" />
               
                
       </div><!--maincontentinner-->
